var express = require('express');
var router = express.Router();
var http=require('http');
const request = require("request");
/* GET home page. */
router.get('/nodeServer', function(req, res, next) {
   var url=req.query.url;
   for (key in req.headers) {
     if (key=="host"||key=="connection"||key=="accept"||key=="origin"||key=="user-agent"||key=="accept-encoding"||key=="accept-language"||key=="if-none-match"||key=="referer") {
      delete req.headers[key];
     }
   }
   var options;
   options={
     url:url,
     headers:req.headers
   }
   request.get(options,function(error,response,body){
   if(error){
      res.send('自己的mock数据')
      return
   } 
   body=JSON.parse(body)
   res.send(body)
   })
  
});

module.exports = router;
